package com.tuozixuan.javafx.control;


import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class WebVeiwDemo extends Application {
	
    public static void main(String[] args) {
        launch(args);
    }

	@Override
	public void start(Stage primaryStage) throws Exception {
		
		WebView webView = new WebView();
		webView.setFontScale(1);
		webView.setZoom(1);
//		webView.setPrefWidth(primaryStage.getWidth());
//		webView.setPrefHeight(primaryStage.getHeight());
		
		WebEngine WebEngine = webView.getEngine();
		
		// 从URL中加载
		String url = "https://www.bejson.com/jsonviewernew/";
//		url = "https://excalidraw.com/";
//		url = "https://app.diagrams.net/";
//		url = "https://www.oracle.com/cn/java/technologies/java-se-api-doc.html";
		WebEngine.load(url);
		
		// 从字符串内容中加载
//		String htmlContent = "<html><body><div style=\"color:red\">hello</div></body></html>";
//		WebEngine.loadContent(htmlContent);
//		webView.setContextMenuEnabled(false);
		
		// 从文件中加载
//		File htmlFile = new File("D:\\1.html");
//		URL htmlFileUrl = htmlFile.toURI().toURL();
//		WebEngine.load(htmlFileUrl.toString());
        
        VBox vbox = new VBox();
        vbox.getChildren().addAll(webView);
        
		
        Scene scene = new Scene(vbox, 2000, 1000);

        primaryStage.setScene(scene);
        primaryStage.sizeToScene();
        primaryStage.show();
	}

}
